# from multiprocessing import Process
#
# x = 1000
#
# def task(name):
#     print(name)
#     global x
#     x = 2
#
#
# if __name__ == '__main__':
#     p1 = Process(target=task,args=('太白',))
#     p1.start()
#
#     print(f'主进程:{x}')


# 上面代码没有做到 主进程一定要在子进程运行之后才执行.
# from multiprocessing import Process
# import time
# x = 1000
#
# def task(name):
#     print(name)
#     global x
#     x = 2
#
# if __name__ == '__main__':
#     p1 = Process(target=task,args=('太白',))
#     p1.start()
#     time.sleep(3)
#     print(f'主进程:{x}')


# 上面已经验证了 子进程与父进程之间的空间隔离.,要验证初始变量是否是一个id.
# 数字-5~256 主进程子进程是沿用同一个.
# from multiprocessing import Process
# import time
# # x = 1000
# x = 255
# # s = 'a'
# # l1 = [1, 2, 3]
#
# def task(name):
#     print(f'子进程:{id(x)}')
#
# if __name__ == '__main__':
#     print(f'主进程:{id(x)}')
#     p1 = Process(target=task,args=('太白',))
#     p1.start()
#     # time.sleep(3)